home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr05 / pwhostb.zip / REDIR.WAS < prev    next >
Text File  |  1993-06-11  |  7KB  |  135 lines

  1. ;REDIR.WAS - Dos Shell Utility 1.00
  2.  
  3. ;*****************************************************************************
  4. ;*                                                                           *
  5. ;* REDIR.WAS                                                                 *
  6. ;* Copyright (C) 1992 Datastorm Technologies, Inc.                           *
  7. ;* All rights reserved.                                                      *
  8. ;*                                                                           *
  9. ;* This script is a demonstration of how to add in the ability to shell to   *
  10. ;* DOS in either the Host.was script or any other script the user desires.   *
  11. ;* This script can be executed from any other script and allows the remote   *
  12. ;* user to redirect DOS output to the COM port currently being used by       *
  13. ;* Procomm Plus.  Since COMMAND.COM is redirecting the DOS output to the     *
  14. ;* COM port, only those commands and programs which use the host machine's   *
  15. ;* BIOS to write to the screen can be redirected to the remote system.       *
  16. ;*                                                                           *
  17. ;* This ASPECT SCRIPT is intended as a sample of ASPECT programming.         *
  18. ;* DATASTORM makes no warranty of any kind, express or implied, including    *
  19. ;* without limitation, any warranties of merchantability and/or fitness      *
  20. ;* for a particular purpose.  Use of this program is at your own risk.       *
  21. ;*                                                                           *
  22. ;* Author: Kevin Bailey                                                      *
  23. ;* Modified by: Jeff Schmidt                                                 *
  24. ;*****************************************************************************
  25.  
  26.  
  27. ;*****************************************************************************
  28. ;* GLOBAL VARIABLES                                                          *
  29. ;*****************************************************************************
  30. long bdrate                               ; Baud Rate of Current Connection
  31. string cport                              ; COM Port Being Used
  32. string pparity                            ; Text Parity Setting
  33. string textline=""                        ; Text to write to file
  34. string filepath                           ; Aspect File Path
  35. string FileUsed                           ; File Path Being Used
  36. string errmsg                             ; Error Message for Remote User
  37. integer dbits                             ; Databits
  38. integer stbits                            ; Stop Bits
  39. integer parnum                            ; Numeric Parity Setting
  40.  
  41.  
  42. ;*****************************************************************************
  43. ;*                                                                           *
  44. ;* MAIN                                                                      *
  45. ;* The main procedure is the only procedure used in this script.  It will    *
  46. ;* create a dos .BAT file which will load COMMAND.COM and redirect it to     *
  47. ;* the current COM port.  It will not allow loading of COMMAND.COM if there  *
  48. ;* is no CARRIER detect on the COM port.                                     *
  49. ;*                                                                           *
  50. ;* Calls: N/A                                                                *
  51. ;* Modifies Globals: bdrate,cport,pparity,textline,errmsg,dbits,stbits       *
  52. ;*                   parnum                                                  *
  53. ;*****************************************************************************
  54. proc main
  55.  
  56.  statmsg ""
  57.  fetch connection port cport                 ; Save the current COM port
  58.  fetch baudrate bdrate                       ; Save the current baud rate
  59.  fetch aspect scriptpath filepath            ; Save Aspect Path
  60.  
  61.  if $carrier                                 ; Make sure we have a CARRIER
  62.  
  63.     assign fileused filepath
  64.     addfilename fileused "redir.bat"         ; Create Path For File
  65.     fopen 0 fileused CREATE TEXT             ; Open BAT file
  66.  
  67.     if success                               ; If file open successful
  68.        fetch port databits dbits             ; Save current data bits
  69.        fetch port stopbits stbits            ; Save current stop bits
  70.        fetch port parity parnum              ; Save Current parity
  71.          switch parnum                       ; Make the text parity setting
  72.           case 0
  73.              assign pparity "n"
  74.           endcase
  75.           case 1
  76.              assign pparity "o"
  77.           endcase
  78.           case 2
  79.              assign pparity "e"
  80.           endcase
  81.           case 3
  82.              assign pparity "m"
  83.           endcase
  84.           case 4
  85.              assign pparity "s"
  86.           endcase
  87.        endswitch
  88.  
  89.                                              ; Make the Mode batch line
  90.        strfmt textline "modex %s: %ld %s %d %d" cport bdrate pparity dbits stbits
  91.        fputs 0 textline
  92.                                              ; Make the Copy Header line
  93.        strfmt textline "copy header.txt %s" cport
  94.        fputs 0 textline
  95.  
  96.        strfmt textline "command %s" cport    ; Make the COMMAND.COM line
  97.        fputs 0 textline
  98.  
  99.        fclose 0                              ; Close the .BAT file
  100.        
  101.        pause 2
  102.        assign fileused filepath
  103.        addfilename fileused "redir.pif"      ; Create PIF File Path
  104.        run fileused MINIMIZED i0             ; Run the .BAT file (was run)
  105.  
  106.        if success                            ; Notify SYSOP
  107.           statmsg "Shelled to Dos on: %s" cport
  108.  
  109.           while istask i0                    ; Loop until .BAT is finished
  110.           endwhile 
  111.  
  112.           assign errmsg ""                   ; No error occurred
  113.  
  114.        else                                  ; .BAT file did not execute
  115.           assign errmsg "Error Shelling to DOS^M^J"
  116.        endif
  117.  
  118.        pause 2
  119.        set baudrate bdrate                   ; Reset baud rate
  120.        transmit errmsg                       ; Send error message
  121.  
  122.      else                                    ; Not able to Shell error
  123.        transmit "Sorry, Unable to Shell to DOS at This Time^M^J"
  124.        transmit "Please notify the SysOp!^M^J"
  125.        statmsg "ERROR: Unable to Create .BAT Shell File."
  126.      endif
  127.  
  128.  else                                        ; No CARRIER
  129.     transmit "Sorry, Unable to Shell to DOS at This Time^M^J"
  130.     transmit "CD Not Asserted on Local Port.^M^J"
  131.     statmsg "ERROR: DOS Shell Aborted (CD Not Asserted on %s)" cport
  132.  endif
  133.  
  134. endproc
  135.